#include "main.h"

#include "drivers.h"
#include "RTOS.h"
#include "tasks.h"




xSemaphoreHandle KeyTask_Ball;


int main(void)
{

	vSetupEnvironment();

	vSemaphoreCreateBinary(KeyTask_Ball);

	xTaskCreate(Task_GreenLED,(signed char *)"GREEN",200,NULL,1,NULL);
	xTaskCreate(Task_BlueLED,(signed char*)"BLUE",200,NULL,2,NULL);
	xTaskCreate(Task_Key,(signed char*)"KEY",200,NULL,3,NULL);

	vTaskStartScheduler();
	uprintf("Should Not Run To This Point\r\n");
	while (1)
	{
	}

}

/**
 * @brief  Set up all the peripheral and devices used in this 
 *  	   system.
 *
 * @param   none
 * @return  none
 * 
 */

void vSetupEnvironment(void)
{
	/*NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);*/
	/*Do not need for this group config as reset value is already for 4bit preemption priority*/
	LED_Init();
	Usart1_Init(115200);
	Key_Init();
	uprintf("Power On With Frequency %d\r\n",(int)Get_SystemClock());
}

#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */

void assert_failed(uint8_t* file, uint32_t line)
{ 

	uprintf("Wrong parameters value: file %s on line %d\r\n", file,(int)line);
	while (1)
	{
	}
}
#endif
